// lib/models/group_model.dart
class Group {
  final String id;
  final String name;
  final String avatarUrl;
  final DateTime createdAt;

  Group({required this.id, required this.name, required this.avatarUrl, required this.createdAt});

  // 从JSON创建Group的工厂方法
  factory Group.fromJson(Map<String, dynamic> json) {
    return Group(
      id: json['id'],
      name: json['name'],
      avatarUrl: json['avatarUrl'],
      createdAt: DateTime.parse(json['createdAt']),
    );
  }

  // 转换为JSON的方法
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'avatarUrl': avatarUrl,
      'createdAt': createdAt.toIso8601String(),
    };
  }
}
